package listbyorder.access101_200.test191;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/15 14:16
 */
public class Solution1 {

    public int hammingWeight(int n) {
        int res = 0;
        int count = 0;
        while (count < 32) {
            if ((n & 1) == 1) {
                res++;
            }
            n = n >> 1;  //n右移一位
            count++;
        }
        return res;
    }
}
